﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web;
using Sharp.Infrastructure.WebApiClient;

namespace Sharp.WebBooter
{
    /// <summary>
    /// 控制台日志显示过滤器
    /// </summary>
    public class ConsoleLoggerActionFilter : IActionFilter
    {
        public void OnActionExecuting(HttpRequestMessage requestMessage)
        {
            Console.WriteLine($"[{requestMessage.Method}] {requestMessage.RequestUri}");
        }

        public Task OnActionExecuted(HttpResponseMessage responseMessage)
        {
            Console.WriteLine($"[{responseMessage.StatusCode} {responseMessage.ReasonPhrase}]");
            return Task.FromResult(true);
        }
    }
}